<%--
  Created by IntelliJ IDEA.
  User: 11200
  Date: 2019/8/30
  Time: 上午 10:51
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="sec" uri="http://www.springframework.org/security/tags" %>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
<html>
<div class="ms-content-layout ">

  <div class="form-horizontal ms-form form-personal-info">
    <div class="block-heading">
      <h5>订单信息</h5>

      <c:if test="${status.canEditCustomInfo()}">
        <h5 class="pull-right">
          <a href="${ctx.host}/reverse-orders/${reverseOrder.id}/edit-order-info" data-toggle="modal"
             data-target="#edit-custom-info">编辑</a></h5>
      </c:if>
    </div>
    <div class="form-group ms-form-group">

      <label class="control-label col-xs-2"><span class="color-red">*&nbsp;</span>订单号：</label>
      <div class="col-xs-2">
        <p class="form-control-static">${reverseOrder.code}</p>
      </div>
      <label class="control-label col-xs-2"><span class="color-red">*&nbsp;</span>创建时间：</label>
      <div class="col-xs-2">
        <p class="form-control-static"><fmt:formatDate value="${reverseOrder.createTime}"
                                                       pattern="yyyy-MM-dd HH:mm"></fmt:formatDate></p>
      </div>
      <label class="control-label col-xs-2"><span class="color-red">*&nbsp;</span>关联一级代理公司：</label>
      <div class="col-xs-2">
        <p class="form-control-static">${empty reverseOrder.primaryAgentCompany.name ? reverseOrder.primaryAgentCompany.companyName : reverseOrder.primaryAgentCompany.name} [${reverseOrder.primaryAgentCompany.type.description}]</p>
      </div>

    </div>

    <div class="form-group ms-form-group">

      <label class="control-label col-xs-2"><span class="color-red">*&nbsp;</span>订单状态：</label>
      <div class="col-xs-2">
        <p class="form-control-static">${reverseOrder.status.description}</p>
      </div>

      <c:if test="${not empty reverseOrder.ticketOrderCode}">
        <label class="control-label col-xs-2"><span class="color-red">*&nbsp;</span>第三方系统订单号：</label>
        <div class="col-xs-2">
          <p class="form-control-static">${reverseOrder.ticketOrderCode}</p>
        </div>
      </c:if>

      <c:if test="${not empty reverseOrder.consumedTime}">
        <label class="control-label col-xs-2"><span class="color-red">*&nbsp;</span>核销时间：</label>
        <div class="col-xs-2">
          <p class="form-control-static"><fmt:formatDate value="${reverseOrder.consumedTime}" pattern="yyyy-MM-dd HH:mm:ss"></fmt:formatDate></p>
        </div>
      </c:if>

    </div>

    <div class="block-heading">
      <h5>航班信息</h5>
      <c:if test="${status.canEditBook()}">
        <h5 class="pull-right"><a href="${ctx.host}/reverse-orders/${reverseOrder.id}/edit-book" data-toggle="modal"
                                  data-target="#edit-book">编辑</a></h5>
      </c:if>
    </div>

    <div class="form-group ms-form-group">
      <label class="control-label col-xs-2"><span class="color-red">*&nbsp;</span>航空公司：</label>
      <div class="col-xs-2">
        <p class="form-control-static">${reverseOrder.aviationBook.bookAirline}</p>
      </div>
      <label class="control-label col-xs-2">备注：</label>
      <div class="col-xs-4">
        <textarea class="form-control-static"
                  style="width: 100%">${reverseOrder.aviationRequest.aviationRequestRemark}</textarea>
      </div>
    </div>

    <table class="table table-hover ms-table">
      <thead>
      <tr>
        <th>往返</th>
        <th>航班号</th>
        <th>舱位</th>
        <th>出发时间（当地时间）</th>
        <th>到达时间（当地时间）</th>
        <th>出发机场</th>
        <th>到达机场</th>
        <th>飞行时间</th>
        <th>+1/-1天</th>
      </tr>
      </thead>
      <tbody>
      <tr>
        <td>往</td>
        <td>${reverseOrder.aviationBook.flightNumber}</td>
        <td>${reverseOrder.aviationBook.position}</td>
        <td>${reverseOrder.aviationBook.departureTime}</td>
        <td>${reverseOrder.aviationBook.arriveTime}</td>
        <td>${reverseOrder.aviationBook.departureLocation}</td>
        <td>${reverseOrder.aviationBook.arriveLocation}</td>
        <td>${reverseOrder.aviationBook.flightTime}</td>
        <td>${reverseOrder.aviationBook.crossDay}</td>
      </tr>

      <c:if test="${not empty reverseOrder.aviationBook && reverseOrder.aviationBook.hasReturnFlight()}">
        <tr>
          <td>返</td>
          <td>${reverseOrder.aviationBook.returnFlightNumber}</td>
          <td>${reverseOrder.aviationBook.position}</td>
          <td>${reverseOrder.aviationBook.returnDepartureTime}</td>
          <td>${reverseOrder.aviationBook.returnArriveTime}</td>
          <td>${reverseOrder.aviationBook.returnDepartureLocation}</td>
          <td>${reverseOrder.aviationBook.returnArriveLocation}</td>
          <td>${reverseOrder.aviationBook.returnFlightTime}</td>
          <td>${reverseOrder.aviationBook.returnCrossDay}</td>
        </tr>
      </c:if>

      </tbody>
    </table>


    <div class="block-heading">
      <h5>价格信息</h5>
      <c:if test="${status.canEditPrice()}">
        <h5 class="pull-right"><a href="${ctx.host}/reverse-orders/${reverseOrder.id}/edit-price" data-toggle="modal"
                                  data-target="#edit-price">编辑</a></h5>
      </c:if>

    </div>
    <div class="form-group ms-form-group">
      <label class="control-label col-xs-2"><span class="color-red">*&nbsp;</span>实际售价：</label>
      <div class="col-xs-2">
        <p class="form-control-static">${reverseOrder.prettyPrice}</p>
      </div>
      <label class="control-label col-xs-2"><span class="color-red">*&nbsp;</span>成本价：</label>
      <div class="col-xs-2">
        <p class="form-control-static">${reverseOrder.prettyCostPrice}</p>
      </div>

    </div>

    <div class="form-group ms-form-group">

      <label class="control-label col-xs-2"><span class="color-red">*&nbsp;</span>支付状态：</label>
      <div class="col-xs-2">
        <p class="form-control-static">${reverseOrder.partialPay ? "部分支付" : reverseOrder.payStatus.description}</p>
      </div>

      <c:if test="${reverseOrder.prettyActualPayPrice > 0}">
        <label class="control-label col-xs-2"><span class="color-red">*&nbsp;</span>实际支付价格：</label>
        <div class="col-xs-2">
          <p class="form-control-static">${reverseOrder.prettyActualPayPrice}</p>
        </div>
      </c:if>

      <c:if test="${reverseOrder.prettyRefundPrice > 0}">
        <label class="control-label col-xs-2"><span class="color-red">*&nbsp;</span>退款金额：</label>
        <div class="col-xs-2">
          <p class="form-control-static">${reverseOrder.prettyRefundPrice}</p>
        </div>
      </c:if>

    </div>

      <div class="form-group ms-form-group">

      <c:if test="${not empty reverseOrder.refundCode}">
        <label class="control-label col-xs-2"><span class="color-red">*&nbsp;</span>退款流水号：</label>
        <div class="col-xs-2">
          <p class="form-control-static">${reverseOrder.refundCode}</p>
        </div>
      </c:if>

      <c:if test="${not empty reverseOrder.lastPayTime}">
        <label class="control-label col-xs-2"><span class="color-red">*&nbsp;</span>最晚支付时间：</label>
        <div class="col-xs-2">
          <p class="form-control-static"><fmt:formatDate value="${reverseOrder.lastPayTime}" pattern="yyyy-MM-dd HH:mm:ss"></fmt:formatDate></p>
        </div>
      </c:if>

    </div>

    <div class="block-heading">
      <h5>客户信息</h5>

      <c:if test="${status.canEditCustomInfo()}">
        <h5 class="pull-right">
          <a href="${ctx.host}/reverse-orders/${reverseOrder.id}/edit-custom-info" data-toggle="modal"
             data-target="#edit-custom-info">编辑</a></h5>
      </c:if>

    </div>

    <div class="form-group ms-form-group">
      <label class="control-label col-xs-2"><span class="color-red">*&nbsp;</span>联系人姓名：</label>
      <div class="col-xs-2">
        <p class="form-control-static">${reverseOrder.customName}</p>
      </div>

      <label class="control-label col-xs-2"><span class="color-red">*&nbsp;</span>联系人电话：</label>
      <div class="col-xs-2">
        <p class="form-control-static">${reverseOrder.customMobile}</p>
      </div>
      <label class="control-label col-xs-2"><span class="color-red">*&nbsp;</span>联系人邮箱：</label>
      <div class="col-xs-2">
        <p class="form-control-static">${reverseOrder.customEmail}</p>
      </div>

    </div>


    <table class="table table-hover ms-table">
      <thead>
      <tr>
        <th>护照号码</th>
        <th>姓氏（拼音）</th>
        <th>名字（拼音）</th>
        <th>性别</th>
        <th>出生日期</th>
        <th>国籍</th>
        <th>护照有效期到期日</th>
        <th>护照签发国</th>
        <th>护照照片</th>
        <th>操作</th>
      </tr>
      </thead>
      <tbody>

      <c:forEach items="${reverseOrder.aviationRequest.aviationUserInfos}" var="info">
        <tr>
          <td>${info.passportCode}</td>
          <td>${info.firstName}</td>
          <td>${info.lastName}</td>
          <td>${info.gender}</td>
          <td><fmt:formatDate value="${info.birthday}" pattern="yyyy-MM-dd" ></fmt:formatDate></td>
          <td>${info.nationality}</td>
          <td><fmt:formatDate value="${info.passportExpirationTime}" pattern="yyyy-MM-dd" /></td>
          <td>${info.passportIssuingCountry}</td>
          <td><a href="${cloudContext.domain}/${info.passportPic}" target="_blank">图片</a></td>
          <td>
            <c:if test="${status.canEditCustomInfo()}">
              <a href="${ctx.host}/reverse-orders/${reverseOrder.id}/edit-aviation-user-info?passportPicCode=${info.passportPic}" data-toggle="modal" data-target="#edit-aviation-user-info">修改</a>
              <a href="${ctx.host}/reverse-orders/${reverseOrder.id}/delete-aviation-user-info?passportPicCode=${info.passportPic}" data-toggle="modal" data-target="#edit-aviation-user-info">删除</a>
            </c:if>
          </td>
        </tr>
      </c:forEach>

      <c:if test="${status.canEditPassengerInfo()}">
        <tr>
          <td> </td>
          <td> </td>
          <td> </td>
          <td> </td>
          <td> </td>
          <td> </td>
          <td> </td>
          <td> </td>
          <td></td>
          <td><a href="${ctx.host}/reverse-orders/${reverseOrder.id}/add-aviation-user-info" data-toggle="modal" data-target="#add-aviation-user-info">添加</a></td>
        </tr>
      </c:if>

      </tbody>
    </table>


    <c:if test="${reverseOrder.onlinePay || reverseOrder.markPay}">
      <div class="block-heading">
        <h5>支付记录</h5>
      </div>

      <c:if test="${not empty paymentContexts}">
        <table class="table table-hover ms-table">
          <thead>
          <tr>
            <th>支付方式</th>
            <th>支付流水号</th>
            <th>支付时间</th>
            <th>支付金额（RMB）</th>
              <%--          <th>支付凭证</th>
                        <th>支付状态</th>
                        <th>标记支付操作人</th>--%>
          </tr>
          </thead>
          <tbody>

          <c:forEach items="${paymentContexts}" var="pcs">
            <tr>
              <td>${enums['PayChannel'][0].codeOf(pcs[3]).description} ${enums['PaymentPayType'][0].codeOf(pcs[4]).description}</td>
              <td>${pcs[12]}</td>
              <td><fmt:formatDate value="${pcs[6]}" pattern="yyyy-MM-dd HH:mm:ss"></fmt:formatDate></td>
              <td>${pcs[1]/100}</td>
                <%--<td><a href="${not empty reverseOrder.payPic ? cloudContext.domain += '/' += reverseOrder.payPic : ''}">支付凭证</a></td>
                <td>${reverseOrder.payStatus.description}</td>
                <td>${reverseOrder.markPayOperator.name}</td>--%>
            </tr>
          </c:forEach>

          </tbody>
        </table>

      </c:if>

      <c:if test="${not empty markPayRecords}">
        <table class="table table-hover ms-table">
          <thead>
          <tr>
            <th>支付方式</th>
            <th>支付流水号</th>
            <th>支付时间</th>
            <th>支付金额（RMB）</th>
            <th>支付凭证</th>
            <th>标记支付操作人</th>
          </tr>
          </thead>
          <tbody>

          <c:forEach items="${markPayRecords}" var="mpr">
            <tr>
              <td>${mpr.payType.description}</td>
              <td>${mpr.payCode}</td>
              <td><fmt:formatDate value="${mpr.markTime}" pattern="yyyy-MM-dd HH:mm:ss"></fmt:formatDate></td>
              <td>${mpr.amount / 100}</td>
              <td><a href="${not empty mpr.payPic ? cloudContext.domain += '/' += mpr.payPic : ''}">支付凭证</a></td>
              <td>${mpr.markOperator.name}</td>
            </tr>
          </c:forEach>

          </tbody>
        </table>

      </c:if>

    </c:if>

    <div class="block-heading">
      <h5>备注信息（客户不可见）</h5>
      <h5 class="pull-right">
        <a href="${ctx.host}/reverse-orders/${reverseOrder.id}/edit-order-remark" data-toggle="modal"
           data-target="#edit-order-remark">编辑</a>
      </h5>
    </div>
    <div class="form-group ms-form-group">
      <div class="col-xs-12">
          <textarea style="width: 100%; height: 100px; resize:none;"
                    readonly>${reverseOrder.orderRemark}</textarea>
      </div>
    </div>

  </div>
</div>
